﻿@model int
@using Ext.Net
@{
    ViewBag.Title = "Edit Vehicle";
    Layout = "~/Views/Shared/_ALayout.cshtml";
}
@section script
{
    <script type="text/javascript">
        function addTab(tabPanel, id, url, title) {
            var tab = tabPanel.getComponent(id);
            if (!tab)
                tab = tabPanel.add({
                    id: id,
                    title: title,
                    closable: 'idVehicleInfo' != id,
                    loader: {
                        url: url,
                        renderer: "frame",
                        loadMask: {
                            showMask: true,
                            msg: "Loading " + title + "..."
                        }
                    }
                });
            tabPanel.setActiveTab(tab);
        }

        function activeVehicleInfo() {
            window.App.mnu.setSelection(window.App.requireInfo);
            window.App.requireInfo.fireEvent('click');
        }

        var _reloadVehicleGroup;

        function manageVehicleGroup(id, callback) {
            _reloadVehicleGroup = callback;
            window.App.winVehicleGroup.show();
            window.App.winVehicleGroup.load();
        }

        function reloadVehicleGroup() {
            if (_reloadVehicleGroup)
                _reloadVehicleGroup();
        }
    </script>
}
@(Html.X()
          .Viewport()
          .Listeners(c =>
                         {
                             c.AfterRender.Handler = "activeVehicleInfo();";
                         })
          .Layout(LayoutType.Border)
          .Items(view =>
                     {
                         view.Add(Html.X()
                                          .Panel()
                                          .Layout(LayoutType.Accordion)
                                          .Region(Region.West)
                                          .Width(170)
                                          .Split(true)
                                          .Items(panel => panel.Add(Html.X()
                                                                            .MenuPanel()
                                                                            .ID("mnu")
                                                                            .Icon(Icon.ArrowSwitch)
                                                                            .Title("Navigation")
                                                                            .Menu(c =>
                                                                                      {
                                                                                          c.Add(Html.X()
                                                                                                        .MenuItem()
                                                                                                        .ID("requireInfo")
                                                                                                        .Text("Thông tin")
                                                                                                        .Icon(Icon.BulletRight)
                                                                                                        .Listeners(v =>
                                                                                                                       {
                                                                                                                           v.Click.Handler = "addTab(#{TabPanel1},'idProductInfo','" + Url.Action("ProductInfo",
                                                                                                                                                                                                       new
                                                                                                                                                                                                           {
                                                                                                                                                                                                               id = Model
                                                                                                                                                                                                           }) + "', 'Thông tin')";
                                                                                                                       }));

                                                                                          c.Add(Html.X()
                                                                                                        .MenuItem()
                                                                                                        .Text("Hình ảnh")
                                                                                                        .Icon(Icon.BulletRight)
                                                                                                        .Listeners(v =>
                                                                                                                       {
                                                                                                                           v.Click.Handler = "addTab(#{TabPanel1},'idImages','" + Url.Action("Images",
                                                                                                                                                                                                        new
                                                                                                                                                                                                            {
                                                                                                                                                                                                                    id = Model
                                                                                                                                                                                                            }) + "', 'Hình ảnh')";
                                                                                                                       }));
                                                                                          c.Add(Html.X()
                                                                                                        .MenuItem()
                                                                                                        .Text("Chi tiết")
                                                                                                        .Icon(Icon.BulletRight)
                                                                                                        .Listeners(v =>
                                                                                                                       {
                                                                                                                           v.Click.Handler = "addTab(#{TabPanel1},'idCustomerInfoSugar','" + Url.Action("Article",
                                                                                                                                                                                                  new
                                                                                                                                                                                                      {
                                                                                                                                                                                                          id = Model
                                                                                                                                                                                                      }) + "', 'Chi tiết')";
                                                                                                                       }));
                                                                                      }))));
                         view.Add(Html.X()
                                          .TabPanel()
                                          .Region(Region.Center)
                                          .ID("TabPanel1"));
                     }))